﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bussiness;
using System.Configuration;

namespace Presentation
{
    public partial class Novedad : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RepeaterNovedades.DataSource = getNovedades();
            RepeaterNovedades.DataBind();
            putImagenNovedad();
        }

        private void putImagenNovedad()
        {
            bool firstRecord = true;
            foreach (DTONovedad n in getNovedades())
            {
                if (n.imagen == null)
                    continue;
                Image i = new Image();
                i.AlternateText = n.imagen.alt;
                i.ImageUrl = ConfigurationManager.AppSettings["ImagesUploadPath"] + n.imagen.ruta;
                i.Height = 340;
                i.ImageAlign = ImageAlign.Middle;
                i.Visible = (firstRecord ? true : false);

                ImagenNovedadPanel.Controls.Add(i);

                firstRecord = false;
            }
        }

        private List<DTONovedad> getNovedades()
        {
            return CatalogoNovedad.getNovedades();
        }
    }
}